package com.ywl.lambda;

import java.util.Arrays;
import java.util.function.Function;
import java.util.function.IntConsumer;

/**
 * lambda练习五
 *
 * @author 24040
 * @name LambdaDemo01
 * @date 2022-08-21 16:30
 */
public class LambdaDemo05 {

    public static void main(String[] args) {
        //匿名内部类
        /*foreachArr(new IntConsumer() {
            @Override
            public void accept(int value) {
                value*=value;
                System.out.println(value);
            }
        });*/

        //Lambda表达式
        foreachArr(value -> System.out.println(value));
    }

    public static void foreachArr(IntConsumer consumer) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        for (int i : arr) {
            consumer.accept(i);
        }

    }

}
